package com.example.util;

import org.apache.tomcat.util.codec.binary.Base64;
import org.springframework.util.DigestUtils;

import java.security.MessageDigest;

/**
 * @Classname Md5Util
 * @Description TODO md5工具类
 * @Version 1.0.0
 * @Date 2023/1/26 17:37
 * @Created by wlh12
 */
public class Md5Util {

    // 秘钥
    private static final String key = "fangwuzupin";
    // 加密算法1
    public static String encode(String password){
        return DigestUtils.md5DigestAsHex((password + key).getBytes());
    }
    // 验证明文是否正确
    public static Boolean decrypt(String encryptPass , String password){
        String encode = encode(password);
        return encode.equals(encryptPass);
    }
    public static void main(String[] args) {
        String encode = encode("123456");
        System.out.println(decrypt("95b50000fe3ea6a1956679d7cce5a30c","123456"));
    }
}
